package orest.back.membermanage;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;

import net.ssta.common.Constants;
import net.ssta.common.DataBaseConfig;
import net.ssta.core.base.BaseException;
import net.ssta.core.db.DBConnectionProvider;
import net.ssta.core.db.DataBaseExecutor;
import net.ssta.core.db.PagingInfo;
import net.ssta.core.db.Record;
import net.ssta.core.db.RecordSet;
import net.ssta.core.util.UUIDGenerator;
import net.ssta.util.bill.UserPoint;
import net.ssta.util.mail.MailConfig;
import net.ssta.util.mail.MailSender;
import net.ssta.util.mail.MailSenderInfo;

import org.apache.log4j.Logger;

import com.rc.sdk.crypt.CryptFactory;


public class UnitUserHandler {
	private static Logger log = Logger.getLogger(UnitUserHandler.class.getClass()); 
	
	/**
	 * 根据机构id获取机构的科技成果信息
	 * @return
	 * @throws SQLException
	 */
	public RecordSet unitAchieveList(String unitid) throws SQLException {
		RecordSet rs=null;
		Connection conn = null;
    	try {
    		
    		conn = DBConnectionProvider.getConnection(Constants.JNDI_SSTA);
	    	DataBaseExecutor dbe = DataBaseExecutor.getExecutor(conn);
	    	String sql = UnitUserSql.getArchieveByUnitid(unitid);
	    	rs=dbe.find(sql);
	    	
		} catch (SQLException e) {
			log.error("获取机构成果信息出错："+e);
			throw e;
		}finally{
			try{
				if(conn != null) conn.close();
			}catch (SQLException e){
				 log.error("关闭conn出错",e);
			}
		}
    	return rs;
	}
	
	/**
	 * 根据科技成果ID获取科技成果详细信息
	 * @return
	 * @throws SQLException
	 */
	public Record achieveInfo(String achieveid) throws SQLException {
		RecordSet rs=null;
		Record record = null;
		Connection conn = null;
    	try {
    		conn = DBConnectionProvider.getConnection(Constants.JNDI_SSTA);
	    	DataBaseExecutor dbe = DataBaseExecutor.getExecutor(conn);
	    	String sql = UnitUserSql.getArchieveInfoById(achieveid);
	    	rs=dbe.find(sql);
	    	
	    	if(rs!=null && rs.size()>0){
	    		record = rs.get(0);
	    	}
		} catch (SQLException e) {
			log.error("获取成果信息出错："+e);
			throw e;
		}finally{
			try{
				if(conn != null) conn.close();
			}catch (SQLException e){
				 log.error("关闭conn出错",e);
			}
		}
    	return record;
	}
	
	
	/**
	 * 获取成果跟踪信息，根据成果uuid，获取成果关联的跟踪信息
	 * **/
	
	
	
}
